//仓库文件
import React from "react";
import { makeAutoObservable } from "mobx";

function createDoubler() {
    return makeAutoObservable({
        menuList: [
            {
                title: "首页",
                path: "SystemHome",
                children: [
                    {
                        title: "系统首页",
                        path: "SystemHome",
                    },
                    {
                        title: "账户设置",
                        path: "AccountSetting",
                    },
                ],
            },
        ],
        productClassify1:
            JSON.parse(sessionStorage.getItem("productClassify1")) || [],
        productClassify2:
            JSON.parse(sessionStorage.getItem("productClassify2")) || [],
        productBrand: JSON.parse(sessionStorage.getItem("productBrand")) || [],
        product: {},


        setMenuList(res) {
            // console.log('res', res);
            if (res == "权限") {
                this.menuList = [
                    {
                        title: "权限",
                        path: "MemberManage",
                        children: [
                            {
                                title: "成员管理",
                                path: "MemberManage",
                            },
                            {
                                title: "角色管理",
                                path: "RoleManage",
                            },
                        ],
                    },
                ];
            } else if (res == "首页") {
                this.menuList = [
                    {
                        title: "首页",
                        path: "SystemHome",
                        children: [
                            {
                                title: "系统首页",
                                path: "SystemHome",
                            },
                            {
                                title: "账户设置",
                                path: "AccountSetting",
                            },
                        ],
                    },
                ];
            } else if (res == "财务") {
                this.menuList = [
                    {
                        title: "财务",
                        path: "Comprehensive",
                        children: [
                            {
                                title: "综合统计",
                                path: "Comprehensive",
                            },
                        ],
                    },
                ];
            } else if (res == "运营") {
                this.menuList = [
                    {
                        title: "运营",
                        path: "Label",
                        children: [
                            {
                                title: "标签管理",
                                path: "Label",
                            },
                            {
                                title: "场景管理",
                                path: "Scene",
                            },
                            {
                                title: "搜索管理",
                                path: "Search",
                            },
                            {
                                title: "专区管理",
                                path: "Zone",
                            },
                            {
                                title: "商品管理",
                                path: "Merchandise",
                            },
                        ],
                    },
                ];
            } else if (res == "订单") {
                this.menuList = [
                    {
                        title: "订单",
                        path: "OrderList",
                        children: [
                            {
                                title: "订单列表",
                                path: "OrderList",
                            },
                            {
                                title: "退换货申请",
                                path: "RefundGoodsList",
                            },
                            {
                                title: "退款申请",
                                path: "RefundMoneyList",
                            },
                            {
                                title: "退换原因设置",
                                path: "RefundReason",
                            },
                        ],
                    },
                ];
            } else if (res == "商品") {
                this.menuList = [
                    {
                        title: "商品",
                        path: "ProductList",
                        children: [
                            {
                                title: "商品添加",
                                path: "AddProduct",
                            },
                            {
                                title: "商品删除",
                                path: "DelProduct",
                            },
                            {
                                title: "商品审核",
                                path: "ProductAudit",
                            },
                            {
                                title: "商品库存设置",
                                path: "ProductChange",
                            },
                            {
                                title: "商品列表",
                                path: "ProductList",
                            },
                        ],
                    },
                ];
            } else if (res == "用户") {
                this.menuList = [
                    {
                        title: "用户",
                        path: "UserList",
                        children: [
                            {
                                title: "用户列表",
                                path: "UserList",
                            },
                            {
                                title: "用户详细",
                                path: "UserDetails",
                            },
                            {
                                title: "购买力筛选",
                                path: "UserPurchasingPower",
                            },
                        ],
                    },
                ];
            } else if (res == "促销") {
                this.menuList = [
                    {
                        title: "促销",
                        path: "DeductionManagement",
                        children: [
                            {
                                title: "抵扣",
                                path: "DeductionManagement",
                            },
                            {
                                title: "促销",
                                path: "PromotionManagement",
                            },
                            {
                                title: "抢购",
                                path: "PurchaseManagement",
                            },
                        ],
                    },
                ];
            } else if (res == "统计") {
                this.menuList = [
                    {
                        title: "统计",
                        path: "Commodity",
                        children: [
                            {
                                title: "商品统计",
                                path: "Commodity",
                            },
                            {
                                title: "交易统计",
                                path: "Transaction",
                            },
                        ],
                    },
                ];
            }
        },

        setProductClassify(res1, res2) {
            /* 
                      往sessionStorage 存用户信息
                      往sessionStorage 存用户权限
                      再去往 store 里面存用户信息、用户权限
                  */
            sessionStorage.setItem("productClassify1", JSON.stringify(res1));
            sessionStorage.setItem("productClassify2", JSON.stringify(res2));
            this.productClassify1 = res1;
            this.productClassify2 = res2;
        },
        setProductBrand(res) {
            /* 
                      往sessionStorage 存用户信息
                      往sessionStorage 存用户权限
                      再去往 store 里面存用户信息、用户权限
                  */
            sessionStorage.setItem("productBrand", JSON.stringify(res));
            this.productBrand = res;
        },
        setProduct(res) {
            this.product = res;
        },
        setProductUrl(res) {
            this.product.productUrl = res;
        },
        promotionHomeEditObj: {},

        // 陈滨婷
        reasonArr: [],//下拉原因列表
        serReasonArr(res) {
            /* 
                往sessionStorage 存用户信息
                往sessionStorage 存用户权限
                再去往 store 里面存用户信息、用户权限
            */
            sessionStorage.setItem('reasonArr', JSON.stringify(res))
            this.reasonArr = res
        },

        checkOrder: {},// 选择订单存入
        selectReasonArr(res) {
            /* 
                往sessionStorage 存用户信息
                往sessionStorage 存用户权限
                再去往 store 里面存用户信息、用户权限
            */
            console.log("存入store里面的额值", res);
            sessionStorage.setItem('checkOrder', JSON.stringify(res))
            this.checkOrder = res
        },
        orderDetails: {},//订单的详情数据
        setorderDetails(res) {
            /* 
                往sessionStorage 存用户信息
                往sessionStorage 存用户权限
                再去往 store 里面存用户信息、用户权限
            */
            console.log("存入store里面的额值", res);
            sessionStorage.setItem('orderDetails', JSON.stringify(res))
            this.orderDetails = res
        },

        promotionHomeEditObj:{},//促销编辑对象
        promotionProductIdObj:{},//促销商品管理id
        deductionEditObj:{},//抵扣编辑对象
        purchaseEditObj:{},//抢购编辑对象
    })
}

let store = createDoubler();

export default store;
